<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>{$text.ld_title}-劳动关系协调</title>
    <link href="/public/static/admin/layui/css/layui.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/public/static/home/css/aui.css" />
    <link href="/public/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/public/static/home/css/base.css" />
    <style>
        header {
            margin-top: 0.75rem;
        }
    </style>
    <div id='wx_pic' style='margin:0 auto;display:none;'>

        <img src='https://exp-picture.cdn.bcebos.com/f367139a310e17995e16860bc9406afec214a393.jpg?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1%2Fquality%2Cq_80' />

    </div>
</head>
<body style="background:#fff">

<div class="content" id="begin_content">
    <!--顶部信息-->
    <div class="project_title">
        <h1><p style="text-align:left;font-size:2rem"><strong>{$text.ld_title}</strong></p></h1>
    </div>
    <div class="desc_begin">
        {$text.ld_description}
    </div>
    <div class="wjhr mtop"></div>
    <!--顶部信息-->
    <ul class="form-list">
        <li>
            <div class="title">1.姓名 <span>*</span></div>
            <div class="input"><input type="text" name="username" id="username" /></div>
        </li>
        <li>
            <div class="title">2.性别 <span>*</span></div>
            <div class="myradio">
                <div>
                    <label><input class="aui-radio sexs" type="radio" value="1" name="sexs" checked> 男 </label>
                </div>
                <div>
                    <label><input class="aui-radio sexs" type="radio" value="0" name="sexs"> 女 </label>
                </div>
            </div>
        </li>
        <!--联系电话-->
        <li>
            <div class="title">3.联系电话 <span>* 【手机号码】</span></div>
            <div class="input"><input type="text" name="phone" id="phone"/></div>
        </li>
        <!--身份证号码-->
        <li>
            <div class="title">4.身份证号码 <span>* 【有效证件号码】</span></div>
            <div class="input"><input type="text" name="idcard" id="idcard"/></div>
        </li>
        <!--户籍所在地-->
        <li>
            <div class="title">5.户籍所在地 <span>* 【与身份证保持一致】</span></div>
            <div class="input" id="distpicker5">
                <select class="form-control" id="province10"></select>
                <select class="form-control" id="city10"></select>
                <select class="form-control" id="district10"></select>
                <input type="text" name="detailmap" id="detailmap" placeholder="详细地址"/>
            </div>
        </li>
        <!--培训性质-->
        <li>
            <div class="title">4.选择培训性质 <span>*</span></div>
            <div class="myradio">
                {foreach $Naturetype as $k=>$v}
                    <div>
                        <label><input class="aui-radio nature" type="radio" value="{$v.id}" name="nature"> {$v.type_name} </label>
                    </div>
                {/foreach}
            </div>
        </li>
        <!--选择专业-->
        <li>
            <div class="title">5.选择专业 <span>*</span></div>
            <div class="myradio">
                {foreach $course as $k=>$v}
                <div>
                    <label><input class="aui-radio course" type="radio" name="course"  value="{$v.id}"> {$v.name} </label>
                </div>
                {/foreach}
            </div>
        </li>
        <!--备注-->
        <li>
            <div class="title">6.备注<span>【其它问题写在这里不要超过255个字，没有问题直接提交】</span></div>
            <div class="input">
                <input type="text" name="comment" id="comment" />
                <div style="margin-left:1rem;color: red;">请确保所有内容填写正确</div>
            </div>
        </li>
        <!--温馨提示-->
        <li>
            <div class="title"></div>
            <section class="_135editor">
                <section style="width: 100%;" data-width="100%">
                    <section style="width: 100%;border: 1px solid red;color:red;" data-width="100%">
                        <section class="135brush" style="font-size: 14px;text-align: justify;letter-spacing: 1.5px;line-height: 1.75em;padding: 1em 0.8em;">
                            <div style="text-align: center;margin-bottom: 1.5rem"><span><strong>☆温馨提示☆</strong></span></div>
                            {$text.ld_wxts}
                        </section>
                    </section>
                    <section style="width: 98%;height: 3px;background:red;margin: 0px auto;" data-width="98%"></section>
                </section>
            </section>
        </li>
        <li>
            <div class="input">
                <button type="button" class="btn btn-info my-button" style="margin-top:3rem;" id="save">提交</button>
            </div>

        </li>
    </ul>
</div>
</body>
<script type="text/javascript" src="/public/static/home/script/api.js" ></script>
<script type="text/javascript">
    apiready = function(){
        api.parseTapmode();
    }
</script>
<script src="/public/static/admin/layui/layui.js"></script>
<script src="/public/static/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="/public/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
<script type="text/javascript" src="/public/static/home/script/api.js"></script>
<script src="/public/static/home/script/distpicker.data.js"></script>
<script src="/public/static/home/script/distpicker.js"></script>
<script src="/public/static/home/script/main.js"></script>
<script>
    //获取性别
    var sexVal = "";
    sexVal = $(".sexs:checked").val();
    $(".sexs").on("click",function(){
        sexVal = $(".sexs:checked").val();
    });
    //获取培训性质
    var natureVal = "";
    $(".nature").on("click",function(){
        natureVal = $(".nature:checked").val();
    });
    //获取选择的专业
    var courseVal = "";
    $(".course").on("click",function(){
        courseVal = $(".course:checked").val();
    });
    layui.use('upload', function() { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer,upload = layui.upload; //独立版的layer无需执行这一句
        //保存
        $("#save").click(function () {
            //判断是否输入了姓名
            if($("#username").val() == ""){
                $("#username").focus();
                layer.msg("请输入姓名", {time: 2000});
                return false;
            }
            //判断是否输入了电话
            if($("#phone").val() == ""){
                $("#phone").focus();
                layer.msg("请输入手机号码", {time: 2000});
                return false;
            }else{
                if(!(/^1[3456789]\d{9}$/.test($("#phone").val()))){
                    $("#phone").focus();
                    layer.msg("手机号码有误，请核实", {time: 2000});
                    return false;
                }
            }
            //判断身份证是否合法
            if($("#idcard").val() == ""){
                $("#idcard").focus();
                layer.msg("请输入身份证号码", {time: 2000});
                return false;
            }else{
                if(!cidInfo($("#idcard").val())){
                    $("#idcard").focus();
                    layer.msg("身份证号码有误，请核实", {time: 2000});
                    return false;
                }
            }
            //判断省是否为空
            if($("#province10").val() == ""){
                $("#province10").focus();
                layer.msg("请选择省", {time: 2000});
                return false;
            }
            //判断市是否为空
            if($("#city10").val() == ""){
                $("#city10").focus();
                layer.msg("请选择市", {time: 2000});
                return false;
            }
            //判断区是否为空
            // if($("#district10").val() == ""){
            //     $("#district10").focus();
            //     layer.msg("请选择区", {time: 2000});
            //     return false;
            // }
            //判断详细是否为空
            if($("#detailmap").val() == ""){
                $("#detailmap").focus();
                layer.msg("请输入详细地址", {time: 2000});
                return false;
            }
            //判断详细是否为空
            if(natureVal == ""){
                layer.msg("请输入选择培训性质", {time: 2000});
                return false;
            }
            //判断详细是否为空
            if(courseVal == ""){
                layer.msg("请输入选择课程", {time: 2000});
                return false;
            }
            $.post("{:url('Index/add')}", {
                username: $("#username").val(),
                sex: sexVal,
                phone: $("#phone").val(),
                idcard: $("#idcard").val(),
                province: $("#province10").val(),
                city: $("#city10").val(),
                district: $("#district10").val(),
                detailmap: $("#detailmap").val(),
                natrueid : natureVal,
                courseid : courseVal,
                comment: $("#comment").val(),
                applytype: "zx",
            }, function (data) {
                layer.msg(data.msg, {time: 2000}, function () {
                    if (data.url) {
                        window.location.href = data.url;
                    }
                });
            });
        });
    });
    //验证身份证是否合法
    var aCity={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州"
        ,53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"}
    function cidInfo(sId){
        var iSum=0
        var info=""
        if(!/^\d{17}(\d|x)$/i.test(sId))return false;
        sId=sId.replace(/x$/i,"a");
        if(aCity[parseInt(sId.substr(0,2))]==null)return false;
        sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2));
        var d=new Date(sBirthday.replace(/-/g,"/"))
        if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))return false;
        for(var i = 17;i>=0;i --) iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 - i),11)
        if(iSum%11!=1)return false;
        return true;
    }

    //获取培训性质
    // var timeVal = new  Array();
    // $("input[name='time']").on("click",function(){
    //      if($(this).prop("checked")){
    //          timeVal.push($(this).val());
    //      }else{
    //          var key = timeVal.indexOf($(this).val());
    //          timeVal.splice(key,1);
    //      }
    // });
</script>
</html>